package com.gao.wechat.util;

import java.io.IOException;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import net.sf.json.JSONObject;

@SuppressWarnings("deprecation")
public class WeChatHttpUtil 
{
	private static final Logger logger = LoggerFactory.getLogger(WeChatHttpUtil.class);
	
	public static final String APPID="wxb9c4c538ac2e11a1";
    public static final String APPSECRET="aac1a7897f010e99798cdb51e7786655";
    
    public static JSONObject doGetJson(String url) throws IOException
    {
    	JSONObject jsonObject = new JSONObject();
        DefaultHttpClient defaultHttpClient=new DefaultHttpClient();
        HttpGet httpGet=new HttpGet(url);
        HttpResponse httpResponse = defaultHttpClient.execute(httpGet);
        HttpEntity httpEntity=httpResponse.getEntity();
        if(httpEntity!=null)
        {
            String result= EntityUtils.toString(httpEntity,"UTF-8");
            jsonObject = JSONObject.fromObject(result);
        }
        httpGet.releaseConnection();
        return jsonObject;
    }
}
